package com.example.serverjava.controller;


import com.example.serverjava.poji.ServerInfo;
import com.example.serverjava.service.ServerServiceImpl;
import com.example.serverjava.utils.R;
import com.example.serverjava.utils.ServerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class ServerController {

    @Autowired
    private ServerServiceImpl serverService;

    @RequestMapping("/server/info")
    public R getInfo(){
        return R.ok().put("data",serverService.getServerInfo());
    }

    @PostMapping("/server/save")
    public R setServer(@RequestBody ServerInfo serverInfo){
        serverService.setServerInfo(serverInfo);
        return R.ok();
    }

    @RequestMapping("/server/netname")
    public R getNetName(){
        return R.ok().put("data",ServerUtil.getNetworkCardConfigureName());
    }
}
